package com.neno.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

/**
 * @Author: root
 * @Date: 2018/11/10 1:17
 */
public class DateUtils {
    private static final String pattern = "yyyy-MM-dd HH:mm:ss";

    //util.Date转成sql.Date
    public static String getDateFormat(String date) {
        try {
            SimpleDateFormat DateFormate = new SimpleDateFormat(pattern);
            java.util.Date date1 = DateFormate.parse(date);
            // System.out.println(date1.getTime());
            java.sql.Timestamp sqlDate = new java.sql.Timestamp(date1.getTime());
            //System.out.println(sqlDate);
            return DateFormate.format(sqlDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
